home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / cyberbal.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  42KB  |  1,430 lines

  1. /***************************************************************************
  2.  
  3. Cyberball Memory Map
  4. --------------------
  5.  
  6. CYBERBALL 68000 MEMORY MAP
  7.  
  8. Function                           Address        R/W  DATA
  9. -------------------------------------------------------------
  10. Program ROM                        000000-07FFFF  R    D0-D15
  11.  
  12. Switch 1 (Player 1)                FC0000         R    D0-D7
  13. Action                                            R    D5
  14. Step (Development Only)                           R    D4
  15. Joystick Left                                     R    D3
  16. Joystick Right                                    R    D2
  17. Joystick Down                                     R    D1
  18. Joystick Up                                       R    D0
  19.  
  20. Switch 2 (Player 2)                FC2000         R    D0-D7
  21. Action                                            R    D5
  22. Step (Development Only)                           R    D4
  23. Joystick Left                                     R    D3
  24. Joystick Right                                    R    D2
  25. Joystick Down                                     R    D1
  26. Joystick Up                                       R    D0
  27.  
  28. Self-Test (Active Low)             FC4000         R    D7
  29. Vertical Blank                                    R    D6
  30. Audio Busy Flag (Active Low)                      R    D5
  31.  
  32. Audio Receive Port                 FC6000         R    D8-D15
  33.  
  34. EEPROM                             FC8000-FC8FFE  R/W  D0-D7
  35.  
  36. Color RAM                          FCA000-FCAFFE  R/W  D0-D15
  37.  
  38. Unlock EEPROM                      FD0000         W    xx
  39. Sound Processor Reset              FD2000         W    xx
  40. Watchdog reset                     FD4000         W    xx
  41. IRQ Acknowledge                    FD6000         W    xx
  42. Audio Send Port                    FD8000         W    D8-D15
  43.  
  44. Playfield RAM                      FF0000-FF1FFF  R/W  D0-D15
  45. Alpha RAM                          FF2000-FF2FFF  R/W  D0-D15
  46. Motion Object RAM                  FF3000-FF3FFF  R/W  D0-D15
  47. RAM                                FF4000-FFFFFF  R/W
  48.  
  49. ****************************************************************************/
  50.  
  51.  
  52. #include "driver.h"
  53. #include "cpu/m6502/m6502.h"
  54. #include "sound/adpcm.h"
  55. #include "machine/atarigen.h"
  56. #include "sndhrdw/atarijsa.h"
  57. #include "vidhrdw/generic.h"
  58.  
  59. #include <math.h>
  60.  
  61.  
  62. /* better to leave this on; otherwise, you end up playing entire games out of the left speaker */
  63. #define USE_MONO_SOUND    1
  64.  
  65. /* don't use this; it's incredibly slow (10k interrupts/second!) and doesn't really work */
  66. /* it's left in primarily for documentation purposes */
  67. /*#define EMULATE_SOUND_68000 1*/
  68.  
  69.  
  70. void cyberbal_set_screen(int which);
  71.  
  72. WRITE_HANDLER( cyberbal_playfieldram_1_w );
  73. WRITE_HANDLER( cyberbal_playfieldram_2_w );
  74.  
  75. WRITE_HANDLER( cyberbal_paletteram_1_w );
  76. READ_HANDLER( cyberbal_paletteram_1_r );
  77. WRITE_HANDLER( cyberbal_paletteram_2_w );
  78. READ_HANDLER( cyberbal_paletteram_2_r );
  79.  
  80. int cyberbal_vh_start(void);
  81. void cyberbal_vh_stop(void);
  82. void cyberbal_vh_screenrefresh(struct osd_bitmap *bitmap, int full_refresh);
  83.  
  84. void cyberbal_scanline_update(int param);
  85.  
  86. extern UINT8 *cyberbal_playfieldram_1;
  87. extern UINT8 *cyberbal_playfieldram_2;
  88.  
  89.  
  90.  
  91. /* internal prototypes and variables */
  92. static void update_sound_68k_interrupts(void);
  93. static void handle_68k_sound_command(int data);
  94.  
  95. static UINT8 *bank_base;
  96. static UINT8 fast_68k_int, io_68k_int;
  97. static UINT8 sound_data_from_68k, sound_data_from_6502;
  98. static UINT8 sound_data_from_68k_ready, sound_data_from_6502_ready;
  99.  
  100.  
  101.  
  102. /*************************************
  103.  *
  104.  *    Initialization
  105.  *
  106.  *************************************/
  107.  
  108. static void update_interrupts(void)
  109. {
  110.     int newstate1 = 0;
  111.     int newstate2 = 0;
  112.     int temp;
  113.  
  114.     if (atarigen_sound_int_state)
  115.         newstate1 |= 1;
  116.     if (atarigen_video_int_state)
  117.         newstate2 |= 1;
  118.  
  119.     if (newstate1)
  120.         cpu_set_irq_line(0, newstate1, ASSERT_LINE);
  121.     else
  122.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  123.  
  124.     if (newstate2)
  125.         cpu_set_irq_line(2, newstate2, ASSERT_LINE);
  126.     else
  127.         cpu_set_irq_line(2, 7, CLEAR_LINE);
  128.  
  129.     /* check for screen swapping */
  130.     temp = input_port_2_r(0);
  131.     if (temp & 1) cyberbal_set_screen(0);
  132.     else if (temp & 2) cyberbal_set_screen(1);
  133. }
  134.  
  135.  
  136. static void init_machine(void)
  137. {
  138.     atarigen_eeprom_reset();
  139.     atarigen_slapstic_reset();
  140.     atarigen_interrupt_reset(update_interrupts);
  141.     atarigen_scanline_timer_reset(cyberbal_scanline_update, 8);
  142.     atarigen_sound_io_reset(1);
  143.  
  144.     /* reset the sound system */
  145.     bank_base = &memory_region(REGION_CPU2)[0x10000];
  146.     cpu_setbank(8, &bank_base[0x0000]);
  147.     fast_68k_int = io_68k_int = 0;
  148.     sound_data_from_68k = sound_data_from_6502 = 0;
  149.     sound_data_from_68k_ready = sound_data_from_6502_ready = 0;
  150.  
  151.     /* CPU 2 doesn't run until reset */
  152.     cpu_set_reset_line(2,ASSERT_LINE);
  153.  
  154.     /* make sure we're pointing to the right screen by default */
  155.     cyberbal_set_screen(0);
  156. }
  157.  
  158.  
  159. static void cyberb2p_update_interrupts(void)
  160. {
  161.     int newstate = 0;
  162.  
  163.     if (atarigen_video_int_state)
  164.         newstate |= 1;
  165.     if (atarigen_sound_int_state)
  166.         newstate |= 3;
  167.  
  168.     if (newstate)
  169.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  170.     else
  171.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  172. }
  173.  
  174.  
  175. static void cyberb2p_init_machine(void)
  176. {
  177.     atarigen_eeprom_reset();
  178.     atarigen_interrupt_reset(cyberb2p_update_interrupts);
  179.     atarigen_scanline_timer_reset(cyberbal_scanline_update, 8);
  180.     atarijsa_reset();
  181.  
  182.     /* make sure we're pointing to the only screen */
  183.     cyberbal_set_screen(0);
  184. }
  185.  
  186.  
  187.  
  188. /*************************************
  189.  *
  190.  *    I/O read dispatch.
  191.  *
  192.  *************************************/
  193.  
  194. static READ_HANDLER( special_port0_r )
  195. {
  196.     int temp = input_port_0_r(offset);
  197.     if (atarigen_cpu_to_sound_ready) temp ^= 0x0080;
  198.     return temp;
  199. }
  200.  
  201.  
  202. static READ_HANDLER( special_port2_r )
  203. {
  204.     int temp = input_port_2_r(offset);
  205.     if (atarigen_cpu_to_sound_ready) temp ^= 0x2000;
  206.     return temp;
  207. }
  208.  
  209.  
  210. static READ_HANDLER( sound_state_r )
  211. {
  212.     int temp = 0xffff;
  213.  
  214.     (void)offset;
  215.     if (atarigen_cpu_to_sound_ready) temp ^= 0xffff;
  216.     return temp;
  217. }
  218.  
  219.  
  220.  
  221. /*************************************
  222.  *
  223.  *    Extra I/O handlers.
  224.  *
  225.  *************************************/
  226.  
  227. static WRITE_HANDLER( p2_reset_w )
  228. {
  229.     (void)offset;
  230.     (void)data;
  231.     cpu_set_reset_line(2,CLEAR_LINE);
  232. }
  233.  
  234.  
  235.  
  236. /*************************************
  237.  *
  238.  *    6502 Sound Interface
  239.  *
  240.  *************************************/
  241.  
  242. static READ_HANDLER( special_port3_r )
  243. {
  244.     int temp = input_port_3_r(offset);
  245.     if (!(readinputport(0) & 0x8000)) temp ^= 0x80;
  246.     if (atarigen_cpu_to_sound_ready) temp ^= 0x40;
  247.     if (atarigen_sound_to_cpu_ready) temp ^= 0x20;
  248.     return temp;
  249. }
  250.  
  251.  
  252. static READ_HANDLER( sound_6502_stat_r )
  253. {
  254.     int temp = 0xff;
  255.  
  256.     (void)offset;
  257.     if (sound_data_from_6502_ready) temp ^= 0x80;
  258.     if (sound_data_from_68k_ready) temp ^= 0x40;
  259.     return temp;
  260. }
  261.  
  262.  
  263. static WRITE_HANDLER( sound_bank_select_w )
  264. {
  265.     (void)offset;
  266.     cpu_setbank(8, &bank_base[0x1000 * ((data >> 6) & 3)]);
  267. }
  268.  
  269.  
  270. static READ_HANDLER( sound_68k_6502_r )
  271. {
  272.     (void)offset;
  273.     sound_data_from_68k_ready = 0;
  274.     return sound_data_from_68k;
  275. }
  276.  
  277.  
  278. static WRITE_HANDLER( sound_68k_6502_w )
  279. {
  280.     (void)offset;
  281.     sound_data_from_6502 = data;
  282.     sound_data_from_6502_ready = 1;
  283.  
  284. #ifdef EMULATE_SOUND_68000
  285.     if (!io_68k_int)
  286.     {
  287.         io_68k_int = 1;
  288.         update_sound_68k_interrupts();
  289.     }
  290. #else
  291.     handle_68k_sound_command(data);
  292. #endif
  293. }
  294.  
  295.  
  296.  
  297. /*************************************
  298.  *
  299.  *    68000 Sound Interface
  300.  *
  301.  *************************************/
  302.  
  303. static void update_sound_68k_interrupts(void)
  304. {
  305. #ifdef EMULATE_SOUND_68000
  306.     int newstate = 0;
  307.  
  308.     if (fast_68k_int)
  309.         newstate |= 6;
  310.     if (io_68k_int)
  311.         newstate |= 2;
  312.  
  313.     if (newstate)
  314.         cpu_set_irq_line(3, newstate, ASSERT_LINE);
  315.     else
  316.         cpu_set_irq_line(3, 7, CLEAR_LINE);
  317. #endif
  318. }
  319.  
  320.  
  321. static int sound_68k_irq_gen(void)
  322. {
  323.     if (!fast_68k_int)
  324.     {
  325.         fast_68k_int = 1;
  326.         update_sound_68k_interrupts();
  327.     }
  328.     return 0;
  329. }
  330.  
  331.  
  332. static WRITE_HANDLER( io_68k_irq_ack_w )
  333. {
  334.     (void)offset;
  335.     (void)data;
  336.     if (io_68k_int)
  337.     {
  338.         io_68k_int = 0;
  339.         update_sound_68k_interrupts();
  340.     }
  341. }
  342.  
  343.  
  344. static READ_HANDLER( sound_68k_r )
  345. {
  346.     int temp = (sound_data_from_6502 << 8) | 0xff;
  347.  
  348.     (void)offset;
  349.     sound_data_from_6502_ready = 0;
  350.  
  351.     if (sound_data_from_6502_ready) temp ^= 0x08;
  352.     if (sound_data_from_68k_ready) temp ^= 0x04;
  353.     return temp;
  354. }
  355.  
  356.  
  357. static WRITE_HANDLER( sound_68k_w )
  358. {
  359.     (void)offset;
  360.     if (!(data & 0xff000000))
  361.     {
  362.         sound_data_from_68k = (data >> 8) & 0xff;
  363.         sound_data_from_68k_ready = 1;
  364.     }
  365. }
  366.  
  367.  
  368. static WRITE_HANDLER( sound_68k_dac_w )
  369. {
  370.     DAC_signed_data_w((offset >> 4) & 1, (INT16)data >> 8);
  371.  
  372.     if (fast_68k_int)
  373.     {
  374.         fast_68k_int = 0;
  375.         update_sound_68k_interrupts();
  376.     }
  377. }
  378.  
  379.  
  380. /*************************************
  381.  *
  382.  *    68000 Sound Simulator
  383.  *
  384.  *************************************/
  385.  
  386. #define SAMPLE_RATE 10000
  387.  
  388. struct sound_descriptor
  389. {
  390.     /*00*/UINT16 start_address_h;
  391.     /*02*/UINT16 start_address_l;
  392.     /*04*/UINT16 end_address_h;
  393.     /*06*/UINT16 end_address_l;
  394.     /*08*/UINT16 reps;
  395.     /*0a*/INT16 volume;
  396.     /*0c*/INT16 delta_volume;
  397.     /*0e*/INT16 target_volume;
  398.     /*10*/UINT16 voice_priority;    /* voice high, priority low */
  399.     /*12*/UINT16 buffer_number;        /* buffer high, number low */
  400.     /*14*/UINT16 continue_unused;    /* continue high, unused low */
  401. };
  402.  
  403. struct voice_descriptor
  404. {
  405.     UINT8 playing;
  406.     UINT8 *start;
  407.     UINT8 *current;
  408.     UINT8 *end;
  409.     UINT16 reps;
  410.     INT16 volume;
  411.     INT16 delta_volume;
  412.     INT16 target_volume;
  413.     UINT8 priority;
  414.     UINT8 number;
  415.     UINT8 buffer;
  416.     UINT8 cont;
  417.     INT16 chunk[48];
  418.     UINT8 chunk_remaining;
  419. };
  420.  
  421.  
  422. static INT16 *volume_table;
  423. static struct voice_descriptor voices[6];
  424. static UINT8 sound_enabled;
  425. static int stream_channel;
  426.  
  427.  
  428. static void decode_chunk(UINT8 *memory, INT16 *output, int overall)
  429. {
  430.     UINT16 volume_bits = READ_WORD(memory);
  431.     int volume, i, j;
  432.  
  433.     memory += 2;
  434.     for (i = 0; i < 3; i++)
  435.     {
  436.         /* get the volume */
  437.         volume = ((overall & 0x03e0) + (volume_bits & 0x3e0)) >> 1;
  438.         volume_bits = ((volume_bits >> 5) & 0x07ff) | ((volume_bits << 11) & 0xf800);
  439.  
  440.         for (j = 0; j < 4; j++)
  441.         {
  442.             UINT16 data = READ_WORD(memory);
  443.             memory += 2;
  444.             *output++ = volume_table[volume | ((data >>  0) & 0x000f)];
  445.             *output++ = volume_table[volume | ((data >>  4) & 0x000f)];
  446.             *output++ = volume_table[volume | ((data >>  8) & 0x000f)];
  447.             *output++ = volume_table[volume | ((data >> 12) & 0x000f)];
  448.         }
  449.     }
  450. }
  451.  
  452.  
  453. static void sample_stream_update(int param, INT16 **buffer, int length)
  454. {
  455.     INT16 *buf_left = buffer[0];
  456.     INT16 *buf_right = buffer[1];
  457.     int i;
  458.  
  459.     (void)param;
  460.  
  461.     /* reset the buffers so we can add into them */
  462.     memset(buf_left, 0, length * sizeof(INT16));
  463.     memset(buf_right, 0, length * sizeof(INT16));
  464.  
  465.     /* loop over voices */
  466.     for (i = 0; i < 6; i++)
  467.     {
  468.         struct voice_descriptor *voice = &voices[i];
  469.         int left = length;
  470.         INT16 *output;
  471.  
  472.         /* bail if not playing */
  473.         if (!voice->playing || !voice->buffer)
  474.             continue;
  475.  
  476.         /* pick a buffer */
  477.         output = (voice->buffer == 0x10) ? buf_left : buf_right;
  478.  
  479.         /* loop until we're done */
  480.         while (left)
  481.         {
  482.             INT16 *source;
  483.             int this_batch;
  484.  
  485.             if (!voice->chunk_remaining)
  486.             {
  487.                 /* loop if necessary */
  488.                 if (voice->current >= voice->end)
  489.                 {
  490.                     if (--voice->reps == 0)
  491.                     {
  492.                         voice->playing = 0;
  493.                         break;
  494.                     }
  495.                     voice->current = voice->start;
  496.                 }
  497.  
  498.                 /* decode this chunk */
  499.                 decode_chunk(voice->current, voice->chunk, voice->volume);
  500.                 voice->current += 26;
  501.                 voice->chunk_remaining = 48;
  502.  
  503.                 /* update volumes */
  504.                 voice->volume += voice->delta_volume;
  505.                 if ((voice->volume & 0xffe0) == (voice->target_volume & 0xffe0))
  506.                     voice->delta_volume = 0;
  507.             }
  508.  
  509.             /* determine how much to copy */
  510.             this_batch = (left > voice->chunk_remaining) ? voice->chunk_remaining : left;
  511.             source = voice->chunk + 48 - voice->chunk_remaining;
  512.             voice->chunk_remaining -= this_batch;
  513.             left -= this_batch;
  514.  
  515.             while (this_batch--)
  516.                 *output++ += *source++;
  517.         }
  518.     }
  519. }
  520.  
  521.  
  522. static int samples_start(const struct MachineSound *msound)
  523. {
  524.     const char *names[] =
  525.     {
  526.         "68000 Simulator left",
  527.         "68000 Simulator right"
  528.     };
  529.     int vol[2], i, j;
  530.  
  531.     (void)msound;
  532.  
  533.     /* allocate volume table */
  534.     volume_table = malloc(sizeof(INT16) * 64 * 16);
  535.     if (!volume_table)
  536.         return 1;
  537.  
  538.     /* build the volume table */
  539.     for (j = 0; j < 64; j++)
  540.     {
  541.         double factor = pow(0.5, (double)j * 0.25);
  542.         for (i = 0; i < 16; i++)
  543.             volume_table[j * 16 + i] = (INT16)(factor * (double)((INT16)(i << 12)));
  544.     }
  545.  
  546.     /* get stream channels */
  547. #if USE_MONO_SOUND
  548.     vol[0] = MIXER(50, MIXER_PAN_CENTER);
  549.     vol[1] = MIXER(50, MIXER_PAN_CENTER);
  550. #else
  551.     vol[0] = MIXER(100, MIXER_PAN_LEFT);
  552.     vol[1] = MIXER(100, MIXER_PAN_RIGHT);
  553. #endif
  554.     stream_channel = stream_init_multi(2, names, vol, SAMPLE_RATE, 0, sample_stream_update);
  555.  
  556.     /* reset voices */
  557.     memset(voices, 0, sizeof(voices));
  558.     sound_enabled = 1;
  559.  
  560.     return 0;
  561. }
  562.  
  563.  
  564. static void samples_stop(void)
  565. {
  566.     if (volume_table)
  567.         free(volume_table);
  568.     volume_table = NULL;
  569. }
  570.  
  571.  
  572. static void handle_68k_sound_command(int command)
  573. {
  574.     struct sound_descriptor *sound;
  575.     struct voice_descriptor *voice;
  576.     UINT16 offset;
  577.     int actual_delta, actual_volume;
  578.     int temp;
  579.  
  580.     /* read the data to reset the latch */
  581.     sound_68k_r(0);
  582.  
  583.     switch (command)
  584.     {
  585.         case 0:        /* reset */
  586.             break;
  587.  
  588.         case 1:        /* self-test */
  589.             sound_68k_w(0, 0x40 << 8);
  590.             break;
  591.  
  592.         case 2:        /* status */
  593.             sound_68k_w(0, 0x00 << 8);
  594.             break;
  595.  
  596.         case 3:
  597.             sound_enabled = 0;
  598.             break;
  599.  
  600.         case 4:
  601.             sound_enabled = 1;
  602.             break;
  603.  
  604.         default:
  605.             /* bail if we're not enabled or if we get a bogus voice */
  606.             offset = READ_WORD(&memory_region(REGION_CPU4)[0x1e2a + 2 * command]);
  607.             sound = (struct sound_descriptor *)&memory_region(REGION_CPU4)[offset];
  608.  
  609.             /* check the voice */
  610.             temp = sound->voice_priority >> 8;
  611.             if (!sound_enabled || temp > 5)
  612.                 break;
  613.             voice = &voices[temp];
  614.  
  615.             /* see if we're allowed to take over */
  616.             actual_volume = sound->volume;
  617.             actual_delta = sound->delta_volume;
  618.             if (voice->playing && voice->cont)
  619.             {
  620.                 temp = sound->buffer_number & 0xff;
  621.                 if (voice->number != temp)
  622.                     break;
  623.  
  624.                 /* if we're ramping, adjust for the current volume */
  625.                 if (actual_delta != 0)
  626.                 {
  627.                     actual_volume = voice->volume;
  628.                     if ((actual_delta < 0 && voice->volume <= sound->target_volume) ||
  629.                         (actual_delta > 0 && voice->volume >= sound->target_volume))
  630.                         actual_delta = 0;
  631.                 }
  632.             }
  633.             else if (voice->playing)
  634.             {
  635.                 temp = sound->voice_priority & 0xff;
  636.                 if (voice->priority > temp ||
  637.                     (voice->priority == temp && (temp & 1) == 0))
  638.                     break;
  639.             }
  640.  
  641.             /* fill in the voice; we're taking over */
  642.             voice->playing = 1;
  643.             voice->start = &memory_region(REGION_CPU4)[(sound->start_address_h << 16) | sound->start_address_l];
  644.             voice->current = voice->start;
  645.             voice->end = &memory_region(REGION_CPU4)[(sound->end_address_h << 16) | sound->end_address_l];
  646.             voice->reps = sound->reps;
  647.             voice->volume = actual_volume;
  648.             voice->delta_volume = actual_delta;
  649.             voice->target_volume = sound->target_volume;
  650.             voice->priority = sound->voice_priority & 0xff;
  651.             voice->number = sound->buffer_number & 0xff;
  652.             voice->buffer = sound->buffer_number >> 8;
  653.             voice->cont = sound->continue_unused >> 8;
  654.             voice->chunk_remaining = 0;
  655.             break;
  656.     }
  657. }
  658.  
  659.  
  660.  
  661. /*************************************
  662.  *
  663.  *    Main CPU memory handlers
  664.  *
  665.  *************************************/
  666.  
  667. static struct MemoryReadAddress main_readmem[] =
  668. {
  669.     { 0x000000, 0x03ffff, MRA_ROM },
  670.     { 0xfc0000, 0xfc03ff, atarigen_eeprom_r },
  671.     { 0xfc8000, 0xfcffff, atarigen_sound_upper_r },
  672.     { 0xfe0000, 0xfe0fff, special_port0_r },
  673.     { 0xfe1000, 0xfe1fff, input_port_1_r },
  674.     { 0xfe8000, 0xfe8fff, cyberbal_paletteram_2_r },
  675.     { 0xfec000, 0xfecfff, cyberbal_paletteram_1_r },
  676.     { 0xff0000, 0xff1fff, MRA_BANK1 },
  677.     { 0xff2000, 0xff3fff, MRA_BANK2 },
  678.     { 0xff4000, 0xff5fff, MRA_BANK3 },
  679.     { 0xff6000, 0xff7fff, MRA_BANK4 },
  680.     { 0xff8000, 0xff9fff, MRA_BANK5 },
  681.     { 0xffa000, 0xffbfff, MRA_BANK6 },
  682.     { 0xffc000, 0xffffff, MRA_BANK7 },
  683.     { -1 }  /* end of table */
  684. };
  685.  
  686. static struct MemoryWriteAddress main_writemem[] =
  687. {
  688.     { 0x000000, 0x03ffff, MWA_ROM },
  689.     { 0xfc0000, 0xfc03ff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  690.     { 0xfd0000, 0xfd1fff, atarigen_eeprom_enable_w },
  691.     { 0xfd2000, 0xfd3fff, atarigen_sound_reset_w },
  692.     { 0xfd4000, 0xfd5fff, watchdog_reset_w },
  693.     { 0xfd6000, 0xfd7fff, p2_reset_w },
  694.     { 0xfd8000, 0xfd9fff, atarigen_sound_upper_w },
  695.     { 0xfe8000, 0xfe8fff, cyberbal_paletteram_2_w, &paletteram_2 },
  696.     { 0xfec000, 0xfecfff, cyberbal_paletteram_1_w, &paletteram },
  697.     { 0xff0000, 0xff1fff, cyberbal_playfieldram_2_w },
  698.     { 0xff2000, 0xff3fff, MWA_BANK2 },
  699.     { 0xff4000, 0xff5fff, cyberbal_playfieldram_1_w },
  700.     { 0xff6000, 0xff7fff, MWA_BANK4 },
  701.     { 0xff8000, 0xff9fff, MWA_BANK5 },
  702.     { 0xffa000, 0xffbfff, MWA_NOP },
  703.     { 0xffc000, 0xffffff, MWA_BANK7 },
  704.     { -1 }  /* end of table */
  705. };
  706.  
  707.  
  708.  
  709. /*************************************
  710.  *
  711.  *    Extra CPU memory handlers
  712.  *
  713.  *************************************/
  714.  
  715. static struct MemoryReadAddress extra_readmem[] =
  716. {
  717.     { 0x000000, 0x03ffff, MRA_ROM },
  718.     { 0xfe0000, 0xfe0fff, special_port0_r },
  719.     { 0xfe1000, 0xfe1fff, input_port_1_r },
  720.     { 0xfe8000, 0xfe8fff, cyberbal_paletteram_2_r },
  721.     { 0xfec000, 0xfecfff, cyberbal_paletteram_1_r },
  722.     { 0xff0000, 0xff1fff, MRA_BANK1 },
  723.     { 0xff2000, 0xff3fff, MRA_BANK2 },
  724.     { 0xff4000, 0xff5fff, MRA_BANK3 },
  725.     { 0xff6000, 0xff7fff, MRA_BANK4 },
  726.     { 0xff8000, 0xff9fff, MRA_BANK5 },
  727.     { 0xffa000, 0xffbfff, MRA_BANK6 },
  728.     { 0xffc000, 0xffffff, MRA_BANK7 },
  729.     { -1 }  /* end of table */
  730. };
  731.  
  732. static struct MemoryWriteAddress extra_writemem[] =
  733. {
  734.     { 0x000000, 0x03ffff, MWA_ROM },
  735.     { 0xfc0000, 0xfdffff, atarigen_video_int_ack_w },
  736.     { 0xfe8000, 0xfe8fff, cyberbal_paletteram_2_w },
  737.     { 0xfec000, 0xfecfff, cyberbal_paletteram_1_w },            /* player 2 palette RAM */
  738.     { 0xff0000, 0xff1fff, cyberbal_playfieldram_2_w, &cyberbal_playfieldram_2 },
  739.     { 0xff2000, 0xff3fff, MWA_BANK2 },
  740.     { 0xff4000, 0xff5fff, cyberbal_playfieldram_1_w, &cyberbal_playfieldram_1, &atarigen_playfieldram_size },
  741.     { 0xff6000, 0xff7fff, MWA_BANK4 },
  742.     { 0xff8000, 0xff9fff, MWA_BANK5 },
  743.     { 0xffa000, 0xffbfff, MWA_BANK6 },
  744.     { 0xffc000, 0xffffff, MWA_NOP },
  745.     { -1 }  /* end of table */
  746. };
  747.  
  748.  
  749.  
  750. /*************************************
  751.  *
  752.  *    Sound CPU memory handlers
  753.  *
  754.  *************************************/
  755.  
  756. struct MemoryReadAddress sound_readmem[] =
  757. {
  758.     { 0x0000, 0x1fff, MRA_RAM },
  759.     { 0x2000, 0x2001, YM2151_status_port_0_r },
  760.     { 0x2802, 0x2803, atarigen_6502_irq_ack_r },
  761.     { 0x2c00, 0x2c01, atarigen_6502_sound_r },
  762.     { 0x2c02, 0x2c03, special_port3_r },
  763.     { 0x2c04, 0x2c05, sound_68k_6502_r },
  764.     { 0x2c06, 0x2c07, sound_6502_stat_r },
  765.     { 0x3000, 0x3fff, MRA_BANK8 },
  766.     { 0x4000, 0xffff, MRA_ROM },
  767.     { -1 }  /* end of table */
  768. };
  769.  
  770.  
  771. struct MemoryWriteAddress sound_writemem[] =
  772. {
  773.     { 0x0000, 0x1fff, MWA_RAM },
  774.     { 0x2000, 0x2000, YM2151_register_port_0_w },
  775.     { 0x2001, 0x2001, YM2151_data_port_0_w },
  776.     { 0x2800, 0x2801, sound_68k_6502_w },
  777.     { 0x2802, 0x2803, atarigen_6502_irq_ack_w },
  778.     { 0x2804, 0x2805, atarigen_6502_sound_w },
  779.     { 0x2806, 0x2807, sound_bank_select_w },
  780.     { 0x3000, 0xffff, MWA_ROM },
  781.     { -1 }  /* end of table */
  782. };
  783.  
  784.  
  785.  
  786. /*************************************
  787.  *
  788.  *    68000 Sound CPU memory handlers
  789.  *
  790.  *************************************/
  791.  
  792. #ifdef EMULATE_SOUND_68000
  793.  
  794. static UINT8 *ram;
  795. static READ_HANDLER( ram_r ) { return READ_WORD(&ram[offset]); }
  796. static WRITE_HANDLER( ram_w ) { COMBINE_WORD_MEM(&ram[offset], data); }
  797.  
  798. static struct MemoryReadAddress sound_68k_readmem[] =
  799. {
  800.     { 0x000000, 0x03ffff, MRA_ROM },
  801.     { 0xff8000, 0xff87ff, sound_68k_r },
  802.     { 0xfff000, 0xffffff, ram_r, &ram },
  803.     { -1 }  /* end of table */
  804. };
  805.  
  806. static struct MemoryWriteAddress sound_68k_writemem[] =
  807. {
  808.     { 0x000000, 0x03ffff, MWA_ROM },
  809.     { 0xff8800, 0xff8fff, sound_68k_w },
  810.     { 0xff9000, 0xff97ff, io_68k_irq_ack_w },
  811.     { 0xff9800, 0xff9fff, sound_68k_dac_w },
  812.     { 0xfff000, 0xffffff, ram_w, &ram },
  813.     { -1 }  /* end of table */
  814. };
  815.  
  816. #endif
  817.  
  818.  
  819.  
  820. /*************************************
  821.  *
  822.  *    2-player main CPU memory handlers
  823.  *
  824.  *************************************/
  825.  
  826. static struct MemoryReadAddress cyberb2p_readmem[] =
  827. {
  828.     { 0x000000, 0x07ffff, MRA_ROM },
  829.     { 0xfc0000, 0xfc0003, input_port_0_r },
  830.     { 0xfc2000, 0xfc2003, input_port_1_r },
  831.     { 0xfc4000, 0xfc4003, special_port2_r },
  832.     { 0xfc6000, 0xfc6003, atarigen_sound_upper_r },
  833.     { 0xfc8000, 0xfc8fff, atarigen_eeprom_r },
  834.     { 0xfca000, 0xfcafff, MRA_BANK1 },
  835.     { 0xfe0000, 0xfe0003, sound_state_r },
  836.     { 0xff0000, 0xff1fff, MRA_BANK2 },
  837.     { 0xff2000, 0xff2fff, MRA_BANK3 },
  838.     { 0xff3000, 0xff3fff, MRA_BANK4 },
  839.     { 0xff4000, 0xffffff, MRA_BANK5 },
  840.     { -1 }  /* end of table */
  841. };
  842.  
  843. static struct MemoryWriteAddress cyberb2p_writemem[] =
  844. {
  845.     { 0x000000, 0x07ffff, MWA_ROM },
  846.     { 0xfc8000, 0xfc8fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  847.     { 0xfca000, 0xfcafff, atarigen_666_paletteram_w, &paletteram },
  848.     { 0xfd0000, 0xfd0003, atarigen_eeprom_enable_w },
  849.     { 0xfd2000, 0xfd2003, atarigen_sound_reset_w },
  850.     { 0xfd4000, 0xfd4003, watchdog_reset_w },
  851.     { 0xfd6000, 0xfd6003, atarigen_video_int_ack_w },
  852.     { 0xfd8000, 0xfd8003, atarigen_sound_upper_w },
  853.     { 0xff0000, 0xff1fff, cyberbal_playfieldram_1_w, &cyberbal_playfieldram_1, &atarigen_playfieldram_size },
  854.     { 0xff2000, 0xff2fff, MWA_BANK3, &atarigen_alpharam, &atarigen_alpharam_size },
  855.     { 0xff3000, 0xff3fff, MWA_BANK4, &atarigen_spriteram, &atarigen_spriteram_size },
  856.     { 0xff4000, 0xffffff, MWA_BANK5 },
  857.     { -1 }  /* end of table */
  858. };
  859.  
  860.  
  861.  
  862. /*************************************
  863.  *
  864.  *    Port definitions
  865.  *
  866.  *************************************/
  867.  
  868. INPUT_PORTS_START( cyberbal )
  869.     PORT_START      /* fe0000 */
  870.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER4 )
  871.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER4 )
  872.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER4 )
  873.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER4 )
  874.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
  875.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER4 )
  876.     PORT_BIT( 0x00c0, IP_ACTIVE_LOW, IPT_UNUSED )
  877.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER3 )
  878.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER3 )
  879.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER3 )
  880.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER3 )
  881.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED )
  882.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  883.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
  884.     PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
  885.  
  886.     PORT_START      /* fe1000 */
  887.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
  888.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
  889.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
  890.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
  891.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
  892.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  893.     PORT_BIT( 0x00c0, IP_ACTIVE_LOW, IPT_UNUSED )
  894.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
  895.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
  896.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
  897.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
  898.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNUSED )
  899.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  900.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
  901.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_VBLANK )
  902.  
  903.     PORT_START        /* fake port for screen switching */
  904.     PORT_BITX(  0x0001, IP_ACTIVE_HIGH, IPT_BUTTON2, "Select Left Screen", KEYCODE_9, IP_JOY_NONE )
  905.     PORT_BITX(  0x0002, IP_ACTIVE_HIGH, IPT_BUTTON2, "Select Right Screen", KEYCODE_0, IP_JOY_NONE )
  906.     PORT_BIT( 0xfffc, IP_ACTIVE_LOW, IPT_UNUSED )
  907.  
  908.     PORT_START        /* audio board port */
  909.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
  910.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
  911.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN4 )
  912.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN3 )
  913.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
  914.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )    /* output buffer full */
  915.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )        /* input buffer full */
  916.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )    /* self test */
  917. INPUT_PORTS_END
  918.  
  919.  
  920. INPUT_PORTS_START( cyberb2p )
  921.     PORT_START      /* fc0000 */
  922.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER1 )
  923.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
  924.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
  925.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
  926.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
  927.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  928.     PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
  929.  
  930.     PORT_START      /* fc2000 */
  931.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_PLAYER2 )
  932.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
  933.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
  934.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
  935.     PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED )
  936.     PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  937.     PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
  938.  
  939.     PORT_START        /* fc4000 */
  940.     PORT_BIT( 0x1fff, IP_ACTIVE_LOW, IPT_UNUSED )
  941.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNUSED )
  942.     PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_VBLANK )
  943.     PORT_SERVICE( 0x8000, IP_ACTIVE_LOW )
  944.  
  945.     JSA_II_PORT        /* audio board port */
  946. INPUT_PORTS_END
  947.  
  948.  
  949.  
  950. /*************************************
  951.  *
  952.  *    Graphics definitions
  953.  *
  954.  *************************************/
  955.  
  956. static struct GfxLayout pflayout =
  957. {
  958.     16,8,    /* 8*8 chars */
  959.     8192,    /* 8192 chars */
  960.     4,        /* 4 bits per pixel */
  961.     { 0, 1, 2, 3 },
  962.     { 0,0, 4,4, 8,8, 12,12, 16,16, 20,20, 24,24, 28,28 },
  963.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  964.     32*8    /* every char takes 32 consecutive bytes */
  965. };
  966.  
  967. static struct GfxLayout anlayout =
  968. {
  969.     16,8,    /* 8*8 chars */
  970.     4096,    /* 4096 chars */
  971.     4,        /* 4 bits per pixel */
  972.     { 0, 1, 2, 3 },
  973.     { 0,0, 4,4, 8,8, 12,12, 16,16, 20,20, 24,24, 28,28 },
  974.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  975.     32*8    /* every char takes 32 consecutive bytes */
  976. };
  977.  
  978. static struct GfxLayout pflayout_interleaved =
  979. {
  980.     16,8,    /* 8*8 chars */
  981.     8192,    /* 8192 chars */
  982.     4,        /* 4 bits per pixel */
  983.     { 0, 1, 2, 3 },
  984.     { 0x20000*8+0,0x20000*8+0, 0x20000*8+4,0x20000*8+4, 0,0, 4,4, 0x20000*8+8,0x20000*8+8, 0x20000*8+12,0x20000*8+12, 8,8, 12,12 },
  985.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  986.     16*8    /* every char takes 16 consecutive bytes */
  987. };
  988.  
  989. static struct GfxLayout anlayout_interleaved =
  990. {
  991.     16,8,    /* 8*8 chars */
  992.     4096,    /* 4096 chars */
  993.     4,        /* 4 bits per pixel */
  994.     { 0, 1, 2, 3 },
  995.     { 0x10000*8+0,0x10000*8+0, 0x10000*8+4,0x10000*8+4, 0,0, 4,4, 0x10000*8+8,0x10000*8+8, 0x10000*8+12,0x10000*8+12, 8,8, 12,12 },
  996.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  997.     16*8    /* every char takes 16 consecutive bytes */
  998. };
  999.  
  1000. static struct GfxLayout molayout =
  1001. {
  1002.     16,8,    /* 8*8 chars */
  1003.     20480,    /* 20480 chars */
  1004.     4,        /* 4 bits per pixel */
  1005.     { 0, 1, 2, 3 },
  1006.     { 0xf0000*8+0, 0xf0000*8+4, 0xa0000*8+0, 0xa0000*8+4, 0x50000*8+0, 0x50000*8+4, 0, 4,
  1007.       0xf0000*8+8, 0xf0000*8+12, 0xa0000*8+8, 0xa0000*8+12, 0x50000*8+8, 0x50000*8+12, 8, 12 },
  1008.     { 0*8, 2*8, 4*8, 6*8, 8*8, 10*8, 12*8, 14*8 },
  1009.     16*8    /* every char takes 16 consecutive bytes */
  1010. };
  1011.  
  1012. static struct GfxDecodeInfo gfxdecodeinfo[] =
  1013. {
  1014.     { REGION_GFX2, 0, &pflayout,     0, 128 },
  1015.     { REGION_GFX1, 0, &molayout, 0x600, 16 },
  1016.     { REGION_GFX3, 0, &anlayout, 0x780, 8 },
  1017.     { -1 } /* end of array */
  1018. };
  1019.  
  1020. static struct GfxDecodeInfo gfxdecodeinfo_interleaved[] =
  1021. {
  1022.     { REGION_GFX2, 0, &pflayout_interleaved,     0, 128 },
  1023.     { REGION_GFX1, 0, &molayout,             0x600, 16 },
  1024.     { REGION_GFX3, 0, &anlayout_interleaved, 0x780, 8 },
  1025.     { -1 } /* end of array */
  1026. };
  1027.  
  1028.  
  1029.  
  1030. /*************************************
  1031.  *
  1032.  *    Sound definitions
  1033.  *
  1034.  *************************************/
  1035.  
  1036. static struct YM2151interface ym2151_interface =
  1037. {
  1038.     1,            /* 1 chip */
  1039.     ATARI_CLOCK_14MHz/4,
  1040. #if USE_MONO_SOUND
  1041.     { YM3012_VOL(30,MIXER_PAN_CENTER,30,MIXER_PAN_CENTER) },
  1042. #else
  1043.     { YM3012_VOL(60,MIXER_PAN_LEFT,60,MIXER_PAN_RIGHT) },
  1044. #endif
  1045.     { atarigen_ym2151_irq_gen }
  1046. };
  1047.  
  1048. #ifdef EMULATE_SOUND_68000
  1049. static struct DACinterface dac_interface =
  1050. {
  1051.     2,
  1052.     { MIXER(100,MIXER_PAN_LEFT), MIXER(100,MIXER_PAN_RIGHT) }
  1053. };
  1054. #endif
  1055.  
  1056. static struct CustomSound_interface samples_interface =
  1057. {
  1058.     samples_start,
  1059.     samples_stop,
  1060.     NULL
  1061. };
  1062.  
  1063.  
  1064. /*************************************
  1065.  *
  1066.  *    Machine driver
  1067.  *
  1068.  *************************************/
  1069.  
  1070. static struct MachineDriver machine_driver_cyberbal =
  1071. {
  1072.     /* basic machine hardware */
  1073.     {
  1074.         {
  1075.             CPU_M68000,        /* verified */
  1076.             ATARI_CLOCK_14MHz/2,
  1077.             main_readmem,main_writemem,0,0,
  1078.             ignore_interrupt,1
  1079.         },
  1080.         {
  1081.             CPU_M6502,
  1082.             ATARI_CLOCK_14MHz/8,
  1083.             sound_readmem,sound_writemem,0,0,
  1084.             0,0,
  1085.             atarigen_6502_irq_gen,(UINT32)(1000000000.0/((double)ATARI_CLOCK_14MHz/4/4/16/16/14))
  1086.         },
  1087.         {
  1088.             CPU_M68000,        /* verified */
  1089.             ATARI_CLOCK_14MHz/2,
  1090.             extra_readmem,extra_writemem,0,0,
  1091.             atarigen_video_int_gen,1
  1092.         }
  1093. #ifdef EMULATE_SOUND_68000
  1094.         ,{
  1095.             CPU_M68000,        /* verified */
  1096.             ATARI_CLOCK_14MHz/2,
  1097.             sound_68k_readmem,sound_68k_writemem,0,0,
  1098.             0,0,
  1099.             sound_68k_irq_gen,10000
  1100.         }
  1101. #endif
  1102.     },
  1103.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  1104.     10,
  1105.     init_machine,
  1106.  
  1107.     /* video hardware */
  1108.     42*16, 30*8, { 0*16, 42*16-1, 0*8, 30*8-1 },
  1109.     gfxdecodeinfo_interleaved,
  1110.     2048, 2048,
  1111.     0,
  1112.  
  1113.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK |
  1114.             VIDEO_PIXEL_ASPECT_RATIO_1_2,
  1115.     0,
  1116.     cyberbal_vh_start,
  1117.     cyberbal_vh_stop,
  1118.     cyberbal_vh_screenrefresh,
  1119.  
  1120.     /* sound hardware */
  1121.     SOUND_SUPPORTS_STEREO,0,0,0,
  1122.     {
  1123.         {
  1124.             SOUND_YM2151,
  1125.             &ym2151_interface
  1126.         },
  1127. #ifdef EMULATE_SOUND_68000
  1128.         {
  1129.             SOUND_DAC,
  1130.             &dac_interface
  1131.         }
  1132. #else
  1133.         {
  1134.             SOUND_CUSTOM,
  1135.             &samples_interface
  1136.         }
  1137. #endif
  1138.     },
  1139.  
  1140.     atarigen_nvram_handler
  1141. };
  1142.  
  1143.  
  1144. static struct MachineDriver machine_driver_cyberb2p =
  1145. {
  1146.     /* basic machine hardware */
  1147.     {
  1148.         {
  1149.             CPU_M68000,        /* verified */
  1150.             ATARI_CLOCK_14MHz/2,
  1151.             cyberb2p_readmem,cyberb2p_writemem,0,0,
  1152.             atarigen_video_int_gen,1
  1153.         },
  1154.         JSA_II_CPU
  1155.     },
  1156.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  1157.     1,
  1158.     cyberb2p_init_machine,
  1159.  
  1160.     /* video hardware */
  1161.     42*16, 30*8, { 0*16, 42*16-1, 0*8, 30*8-1 },
  1162.     gfxdecodeinfo,
  1163.     2048, 2048,
  1164.     0,
  1165.  
  1166.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK |
  1167.             VIDEO_PIXEL_ASPECT_RATIO_1_2,
  1168.     0,
  1169.     cyberbal_vh_start,
  1170.     cyberbal_vh_stop,
  1171.     cyberbal_vh_screenrefresh,
  1172.  
  1173.     /* sound hardware */
  1174.     JSA_II_MONO(REGION_SOUND1),
  1175.  
  1176.     atarigen_nvram_handler
  1177. };
  1178.  
  1179.  
  1180.  
  1181. /*************************************
  1182.  *
  1183.  *    ROM definition(s)
  1184.  *
  1185.  *************************************/
  1186.  
  1187. ROM_START( cyberbal )
  1188.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  1189.     ROM_LOAD_EVEN( "4123.1m", 0x00000, 0x10000, 0xfb872740 )
  1190.     ROM_LOAD_ODD ( "4124.1k", 0x00000, 0x10000, 0x87babad9 )
  1191.  
  1192.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k for 6502 code */
  1193.     ROM_LOAD( "2131-snd.2f",  0x10000, 0x4000, 0xbd7e3d84 )
  1194.     ROM_CONTINUE(             0x04000, 0xc000 )
  1195.  
  1196.     ROM_REGION( 0x40000, REGION_CPU3 )    /* 4*64k for 68000 code */
  1197.     ROM_LOAD_EVEN( "2127.3c", 0x00000, 0x10000, 0x3e5feb1f )
  1198.     ROM_LOAD_ODD ( "2128.1b", 0x00000, 0x10000, 0x4e642cc3 )
  1199.     ROM_LOAD_EVEN( "2129.1c", 0x20000, 0x10000, 0xdb11d2f0 )
  1200.     ROM_LOAD_ODD ( "2130.3b", 0x20000, 0x10000, 0xfd86b8aa )
  1201.  
  1202.     ROM_REGION( 0x40000, REGION_CPU4 )    /* 256k for 68000 sound code */
  1203.     ROM_LOAD_EVEN( "1132-snd.5c",  0x00000, 0x10000, 0xca5ce8d8 )
  1204.     ROM_LOAD_ODD ( "1133-snd.7c",  0x00000, 0x10000, 0xffeb8746 )
  1205.     ROM_LOAD_EVEN( "1134-snd.5a",  0x20000, 0x10000, 0xbcbd4c00 )
  1206.     ROM_LOAD_ODD ( "1135-snd.7a",  0x20000, 0x10000, 0xd520f560 )
  1207.  
  1208.     ROM_REGION( 0x140000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  1209.     ROM_LOAD( "1150.15a",  0x000000, 0x10000, 0xe770eb3e ) /* MO */
  1210.     ROM_LOAD( "1154.16a",  0x010000, 0x10000, 0x40db00da ) /* MO */
  1211.     ROM_LOAD( "2158.17a",  0x020000, 0x10000, 0x52bb08fb ) /* MO */
  1212.     ROM_LOAD( "1162.19a",  0x030000, 0x10000, 0x0a11d877 ) /* MO */
  1213.  
  1214.     ROM_LOAD( "1151.11a",  0x050000, 0x10000, 0x6f53c7c1 ) /* MO */
  1215.     ROM_LOAD( "1155.12a",  0x060000, 0x10000, 0x5de609e5 ) /* MO */
  1216.     ROM_LOAD( "2159.13a",  0x070000, 0x10000, 0xe6f95010 ) /* MO */
  1217.     ROM_LOAD( "1163.14a",  0x080000, 0x10000, 0x47f56ced ) /* MO */
  1218.  
  1219.     ROM_LOAD( "1152.15c",  0x0a0000, 0x10000, 0xc8f1f7ff ) /* MO */
  1220.     ROM_LOAD( "1156.16c",  0x0b0000, 0x10000, 0x6bf0bf98 ) /* MO */
  1221.     ROM_LOAD( "2160.17c",  0x0c0000, 0x10000, 0xc3168603 ) /* MO */
  1222.     ROM_LOAD( "1164.19c",  0x0d0000, 0x10000, 0x7ff29d09 ) /* MO */
  1223.  
  1224.     ROM_LOAD( "1153.11c",  0x0f0000, 0x10000, 0x99629412 ) /* MO */
  1225.     ROM_LOAD( "1157.12c",  0x100000, 0x10000, 0xaa198cb7 ) /* MO */
  1226.     ROM_LOAD( "2161.13c",  0x110000, 0x10000, 0x6cf79a67 ) /* MO */
  1227.     ROM_LOAD( "1165.14c",  0x120000, 0x10000, 0x40bdf767 ) /* MO */
  1228.  
  1229.     ROM_REGION( 0x040000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  1230.     ROM_LOAD( "1146.9l",   0x000000, 0x10000, 0xa64b4da8 ) /* playfield */
  1231.     ROM_LOAD( "1147.8l",   0x010000, 0x10000, 0xca91ec1b ) /* playfield */
  1232.     ROM_LOAD( "1148.11l",  0x020000, 0x10000, 0xee29d1d1 ) /* playfield */
  1233.     ROM_LOAD( "1149.10l",  0x030000, 0x10000, 0x882649f8 ) /* playfield */
  1234.  
  1235.     ROM_REGION( 0x020000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  1236.     ROM_LOAD( "1166.14n",  0x000000, 0x10000, 0x0ca1e3b3 ) /* alphanumerics */
  1237.     ROM_LOAD( "1167.16n",  0x010000, 0x10000, 0x882f4e1c ) /* alphanumerics */
  1238. ROM_END
  1239.  
  1240.  
  1241. ROM_START( cyberbt )
  1242.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 4*64k for 68000 code */
  1243.     ROM_LOAD_EVEN( "cyb1007.bin", 0x00000, 0x10000, 0xd434b2d7 )
  1244.     ROM_LOAD_ODD ( "cyb1008.bin", 0x00000, 0x10000, 0x7d6c4163 )
  1245.     ROM_LOAD_EVEN( "cyb1009.bin", 0x20000, 0x10000, 0x3933e089 )
  1246.     ROM_LOAD_ODD ( "cyb1010.bin", 0x20000, 0x10000, 0xe7a7cae8 )
  1247.  
  1248.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k for 6502 code */
  1249.     ROM_LOAD( "cyb1029.bin",  0x10000, 0x4000, 0xafee87e1 )
  1250.     ROM_CONTINUE(             0x04000, 0xc000 )
  1251.  
  1252.     ROM_REGION( 0x40000, REGION_CPU3 )
  1253.     ROM_LOAD_EVEN( "cyb1011.bin", 0x00000, 0x10000, 0x22d3e09c )
  1254.     ROM_LOAD_ODD ( "cyb1012.bin", 0x00000, 0x10000, 0xa8eeed8c )
  1255.     ROM_LOAD_EVEN( "cyb1013.bin", 0x20000, 0x10000, 0x11d287c9 )
  1256.     ROM_LOAD_ODD ( "cyb1014.bin", 0x20000, 0x10000, 0xbe15db42 )
  1257.  
  1258.     ROM_REGION( 0x40000, REGION_CPU4 )    /* 256k for 68000 sound code */
  1259.     ROM_LOAD_EVEN( "1132-snd.5c",  0x00000, 0x10000, 0xca5ce8d8 )
  1260.     ROM_LOAD_ODD ( "1133-snd.7c",  0x00000, 0x10000, 0xffeb8746 )
  1261.     ROM_LOAD_EVEN( "1134-snd.5a",  0x20000, 0x10000, 0xbcbd4c00 )
  1262.     ROM_LOAD_ODD ( "1135-snd.7a",  0x20000, 0x10000, 0xd520f560 )
  1263.  
  1264.     ROM_REGION( 0x140000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  1265.     ROM_LOAD( "1001.bin",  0x000000, 0x20000, 0x586ba107 ) /* MO */
  1266.     ROM_LOAD( "1005.bin",  0x020000, 0x20000, 0xa53e6248 ) /* MO */
  1267.     ROM_LOAD( "1032.bin",  0x040000, 0x10000, 0x131f52a0 ) /* MO */
  1268.  
  1269.     ROM_LOAD( "1002.bin",  0x050000, 0x20000, 0x0f71f86c ) /* MO */
  1270.     ROM_LOAD( "1006.bin",  0x070000, 0x20000, 0xdf0ab373 ) /* MO */
  1271.     ROM_LOAD( "1033.bin",  0x090000, 0x10000, 0xb6270943 ) /* MO */
  1272.  
  1273.     ROM_LOAD( "1003.bin",  0x0a0000, 0x20000, 0x1cf373a2 ) /* MO */
  1274.     ROM_LOAD( "1007.bin",  0x0c0000, 0x20000, 0xf2ffab24 ) /* MO */
  1275.     ROM_LOAD( "1034.bin",  0x0e0000, 0x10000, 0x6514f0bd ) /* MO */
  1276.  
  1277.     ROM_LOAD( "1004.bin",  0x0f0000, 0x20000, 0x537f6de3 ) /* MO */
  1278.     ROM_LOAD( "1008.bin",  0x110000, 0x20000, 0x78525bbb ) /* MO */
  1279.     ROM_LOAD( "1035.bin",  0x130000, 0x10000, 0x1be3e5c8 ) /* MO */
  1280.  
  1281.     ROM_REGION( 0x040000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  1282.     ROM_LOAD( "cyb1015.bin",  0x000000, 0x10000, 0xdbbad153 ) /* playfield */
  1283.     ROM_LOAD( "cyb1016.bin",  0x010000, 0x10000, 0x76e0d008 ) /* playfield */
  1284.     ROM_LOAD( "cyb1017.bin",  0x020000, 0x10000, 0xddca9ca2 ) /* playfield */
  1285.     ROM_LOAD( "cyb1018.bin",  0x030000, 0x10000, 0xaa495b6f ) /* playfield */
  1286.  
  1287.     ROM_REGION( 0x020000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  1288.     ROM_LOAD( "cyb1019.bin",  0x000000, 0x10000, 0x833b4768 ) /* alphanumerics */
  1289.     ROM_LOAD( "cyb1020.bin",  0x010000, 0x10000, 0x4976cffd ) /* alphanumerics */
  1290. ROM_END
  1291.  
  1292.  
  1293. ROM_START( cyberb2p )
  1294.     ROM_REGION( 0x80000, REGION_CPU1 )    /* 8*64k for 68000 code */
  1295.     ROM_LOAD_EVEN( "3019.bin", 0x00000, 0x10000, 0x029f8cb6 )
  1296.     ROM_LOAD_ODD ( "3020.bin", 0x00000, 0x10000, 0x1871b344 )
  1297.     ROM_LOAD_EVEN( "3021.bin", 0x20000, 0x10000, 0xfd7ebead )
  1298.     ROM_LOAD_ODD ( "3022.bin", 0x20000, 0x10000, 0x173ccad4 )
  1299.     ROM_LOAD_EVEN( "2023.bin", 0x40000, 0x10000, 0xe541b08f )
  1300.     ROM_LOAD_ODD ( "2024.bin", 0x40000, 0x10000, 0x5a77ee95 )
  1301.     ROM_LOAD_EVEN( "1025.bin", 0x60000, 0x10000, 0x95ff68c6 )
  1302.     ROM_LOAD_ODD ( "1026.bin", 0x60000, 0x10000, 0xf61c4898 )
  1303.  
  1304.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k for 6502 code */
  1305.     ROM_LOAD( "1042.bin",  0x10000, 0x4000, 0xe63cf125 )
  1306.     ROM_CONTINUE(          0x04000, 0xc000 )
  1307.  
  1308.     ROM_REGION( 0x140000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  1309.     ROM_LOAD( "1001.bin",  0x000000, 0x20000, 0x586ba107 ) /* MO */
  1310.     ROM_LOAD( "1005.bin",  0x020000, 0x20000, 0xa53e6248 ) /* MO */
  1311.     ROM_LOAD( "1032.bin",  0x040000, 0x10000, 0x131f52a0 ) /* MO */
  1312.  
  1313.     ROM_LOAD( "1002.bin",  0x050000, 0x20000, 0x0f71f86c ) /* MO */
  1314.     ROM_LOAD( "1006.bin",  0x070000, 0x20000, 0xdf0ab373 ) /* MO */
  1315.     ROM_LOAD( "1033.bin",  0x090000, 0x10000, 0xb6270943 ) /* MO */
  1316.  
  1317.     ROM_LOAD( "1003.bin",  0x0a0000, 0x20000, 0x1cf373a2 ) /* MO */
  1318.     ROM_LOAD( "1007.bin",  0x0c0000, 0x20000, 0xf2ffab24 ) /* MO */
  1319.     ROM_LOAD( "1034.bin",  0x0e0000, 0x10000, 0x6514f0bd ) /* MO */
  1320.  
  1321.     ROM_LOAD( "1004.bin",  0x0f0000, 0x20000, 0x537f6de3 ) /* MO */
  1322.     ROM_LOAD( "1008.bin",  0x110000, 0x20000, 0x78525bbb ) /* MO */
  1323.     ROM_LOAD( "1035.bin",  0x130000, 0x10000, 0x1be3e5c8 ) /* MO */
  1324.  
  1325.     ROM_REGION( 0x040000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  1326.     ROM_LOAD( "1036.bin",  0x000000, 0x10000, 0xcdf6e3d6 ) /* playfield */
  1327.     ROM_LOAD( "1037.bin",  0x010000, 0x10000, 0xec2fef3e ) /* playfield */
  1328.     ROM_LOAD( "1038.bin",  0x020000, 0x10000, 0xe866848f ) /* playfield */
  1329.     ROM_LOAD( "1039.bin",  0x030000, 0x10000, 0x9b9a393c ) /* playfield */
  1330.  
  1331.     ROM_REGION( 0x020000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  1332.     ROM_LOAD( "1040.bin",  0x000000, 0x10000, 0xa4c116f9 ) /* alphanumerics */
  1333.     ROM_LOAD( "1041.bin",  0x010000, 0x10000, 0xe25d7847 ) /* alphanumerics */
  1334.  
  1335.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* 256k for ADPCM samples */
  1336.     ROM_LOAD( "1049.bin",  0x00000, 0x10000, 0x94f24575 )
  1337.     ROM_LOAD( "1050.bin",  0x10000, 0x10000, 0x87208e1e )
  1338.     ROM_LOAD( "1051.bin",  0x20000, 0x10000, 0xf82558b9 )
  1339.     ROM_LOAD( "1052.bin",  0x30000, 0x10000, 0xd96437ad )
  1340. ROM_END
  1341.  
  1342.  
  1343.  
  1344. /*************************************
  1345.  *
  1346.  *    Machine initialization
  1347.  *
  1348.  *************************************/
  1349.  
  1350. static const UINT16 default_eeprom[] =
  1351. {
  1352.     0x0001,0x01FF,0x0F00,0x011A,0x014A,0x0100,0x01A1,0x0200,
  1353.     0x010E,0x01AF,0x0300,0x01FF,0x0114,0x0144,0x01FF,0x0F00,
  1354.     0x011A,0x014A,0x0100,0x01A1,0x0200,0x010E,0x01AF,0x0300,
  1355.     0x01FF,0x0114,0x0144,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,
  1356.     0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,
  1357.     0x0E00,0x01A8,0x0131,0x010B,0x0100,0x014C,0x0A00,0x01FF,
  1358.     0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0xB5FF,0x0E00,0x01FF,
  1359.     0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,
  1360.     0x0E00,0x01FF,0x0E00,0x0000
  1361. };
  1362.  
  1363. static void init_cyberbal(void)
  1364. {
  1365.     atarigen_eeprom_default = default_eeprom;
  1366.     atarigen_slapstic_init(0, 0x018000, 0);
  1367.  
  1368.     /* make sure the banks are pointing to the correct location */
  1369.     cpu_setbank(1, cyberbal_playfieldram_2);
  1370.     cpu_setbank(3, cyberbal_playfieldram_1);
  1371.  
  1372.     /* display messages */
  1373. /*    atarigen_show_slapstic_message(); -- no slapstic */
  1374.     atarigen_show_sound_message();
  1375.  
  1376.     /* speed up the 6502 */
  1377.     atarigen_init_6502_speedup(1, 0x4191, 0x41A9);
  1378.  
  1379.     atarigen_playfieldram = cyberbal_playfieldram_1;
  1380. }
  1381.  
  1382.  
  1383. static void init_cyberbt(void)
  1384. {
  1385.     atarigen_eeprom_default = default_eeprom;
  1386.     atarigen_slapstic_init(0, 0x018000, 116);
  1387.  
  1388.     /* make sure the banks are pointing to the correct location */
  1389.     cpu_setbank(1, cyberbal_playfieldram_2);
  1390.     cpu_setbank(3, cyberbal_playfieldram_1);
  1391.  
  1392.     /* display messages */
  1393. /*    atarigen_show_slapstic_message(); -- no known slapstic problems - yet! */
  1394.     atarigen_show_sound_message();
  1395.  
  1396.     /* speed up the 6502 */
  1397.     atarigen_init_6502_speedup(1, 0x4191, 0x41A9);
  1398.  
  1399.     atarigen_playfieldram = cyberbal_playfieldram_1;
  1400. }
  1401.  
  1402.  
  1403. static void init_cyberb2p(void)
  1404. {
  1405.     atarigen_eeprom_default = default_eeprom;
  1406.  
  1407.     /* initialize the JSA audio board */
  1408.     atarijsa_init(1, 3, 2, 0x8000);
  1409.  
  1410.     /* display messages */
  1411.     atarigen_show_sound_message();
  1412.  
  1413.     /* speed up the 6502 */
  1414.     atarigen_init_6502_speedup(1, 0x4159, 0x4171);
  1415.  
  1416.     atarigen_playfieldram = cyberbal_playfieldram_1;
  1417. }
  1418.  
  1419.  
  1420.  
  1421. /*************************************
  1422.  *
  1423.  *    Game driver(s)
  1424.  *
  1425.  *************************************/
  1426.  
  1427. GAME( 1988, cyberbal, 0,        cyberbal, cyberbal, cyberbal, ROT0_16BIT, "Atari Games", "Cyberball" )
  1428. GAME( 1989, cyberbt,  cyberbal, cyberbal, cyberbal, cyberbt,  ROT0_16BIT, "Atari Games", "Tournament Cyberball 2072" )
  1429. GAME( 1989, cyberb2p, cyberbal, cyberb2p, cyberb2p, cyberb2p, ROT0_16BIT, "Atari Games", "Cyberball 2072 (2 player)" )
  1430.